﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UserScript.ExpressionParsing.Irony.Parsing {
  internal class ParsingEventArgs : EventArgs {
    internal readonly ParsingContext Context;
    internal ParsingEventArgs(ParsingContext context) {
      Context = context;
    }
  }

  internal class ReducedEventArgs : ParsingEventArgs {
    internal readonly Production ReducedProduction;
    internal readonly ParseTreeNode ResultNode;
    internal ReducedEventArgs(ParsingContext context, Production reducedProduction, ParseTreeNode resultNode) : base(context) {
      ReducedProduction = reducedProduction;
      ResultNode = resultNode; 
    }
  }

  internal class ValidateTokenEventArgs : ParsingEventArgs {
    internal ValidateTokenEventArgs(ParsingContext context) : base(context) { }

    internal Token Token {
      get { return Context.CurrentToken; }
    }//Token

    internal void ReplaceToken(Token token) {
      Context.CurrentToken = token; 
    }
    internal void SetError(string errorMessage, params object[] messageArgs) {
      Context.CurrentToken = Context.CreateErrorToken(errorMessage, messageArgs); 
    }
    //Rejects the token; use it when there's more than one terminal that can be used to scan the input and ValidateToken is used
    // to help Scanner make the decision. Once the token is rejected, the scanner will move to the next Terminal (with lower priority)
    // and will try to produce token. 
    internal void RejectToken() {
      Context.CurrentToken = null; 
    }
  }//class

}//namespace
